<?php
namespace app\entity;

/**
 * 班级实体，与数据表进行对应（映射）
 * */
class Clazz {
    public $id;

    public $createTime;

    /**
     * 多对一
     * */
    public $createUser;

    /**
     * 入学日期
     * */
    public $entranceDate;

    public $name;

    // 学生数量
    public $numberOfStudents;

    // 班主任
    public $user;

    public function __construct($row = []) {
        $this->createUser = new User();
        $this->user = new User();
        if (isset($row['id'])) {
            $this->id = (int) $row['id'];
        }

        if (isset($row['name'])) {
            $this->name = $row['name'];
        }     

        if (isset($row['name'])) {
            $this->name = $row['name'];
        }      

        if (isset($row['entrance_date'])) {
            $this->entranceDate = (int) $row['entrance_date'];
        }        
        
        if (isset($row['number_of_students'])) {
            $this->numberOfStudents = (int) $row['number_of_students'];
        }   

        if (isset($row['create_time'])) {
            $this->createTime = $row['create_time'];
        }
        
        if (isset($row['user.name'])) {
            $this->user->name = $row['user.name'];
        }

        if (isset($row['user.id'])) {
            $this->user->id = (int) $row['user.id'];
        }

        if (isset($row['create_user.name'])) {
            $this->createUser->name = $row['create_user.name'];
        }

        if (isset($row['create_user.id'])) {
            $this->createUser->id = (int) $row['create_user.id'];
        }
    }
}